define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    if(Config.type == '' || Config.type == null){
        Config.type = 0;
    }
    if(Config.operation_id == '' || Config.operation_id == null){
        Config.operation_id = 0;
    }
    if(Config.urlid == '' || Config.urlid == null){
        Config.urlid = 0;
    }
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'feditionlog/index/?type=' + Config.type + '&operation_id=' + Config.operation_id + '&urlid=' + Config.urlid,
                    add_url: 'feditionlog/add/?type=' + Config.type + '&operation_id=' + Config.operation_id + '&urlid=' + Config.urlid,
                    edit_url: 'feditionlog/edit',
                    del_url: 'feditionlog/del',
                    multi_url: 'feditionlog/multi',
                    import_url: 'feditionlog/import',
                    table: 'fedition_log',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'createtime',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'admin_id', title: __('Username'),visible: false,addClass: "selectpage", extend: "data-source='auth/admin/index' data-field='nickname'"},
                        {field: 'username', title: __('Username'), operate: false},
                        {field: 'title', title: __('Title'), operate: 'LIKE'},
                        {field: 'content', title: __('Content'), operate: 'LIKE'},
                        {field: 'ip', title: __('Ip'), operate: 'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});